package com.darksides.lenditweb.client.util.locale;

import com.google.gwt.user.client.Cookies;

/**
 * @author Benjamin Barbier
 *
 */
public class LocaleUtils {

        private static final LocaleUtils singleton = new LocaleUtils();
        
        private LocaleUtils(){}
        
        public static LocaleUtils getInstance() {return singleton;}
        
        public Locale getLocale() {
                String language = Cookies.getCookie("language");
                if (language!=null) {
                        if (language.equals(Locale.FRENCH.getLanguage()))  return Locale.FRENCH;
                        if (language.equals(Locale.ENGLISH.getLanguage())) return Locale.ENGLISH;
                        if (language.equals(Locale.ITALIAN.getLanguage())) return Locale.ITALIAN;
                        if (language.equals(Locale.SPANISH.getLanguage())) return Locale.SPANISH;
                        if (language.equals(Locale.GERMAN.getLanguage()))  return Locale.GERMAN;
                } else {
                        // return default Language
                        return Locale.FRENCH;   
                }
                return null;
        }
        
}
